<template>
  <div class="evaAddque">
    <el-card>
      <el-tabs v-model="activeName" @tab-click="handleClick" class="card_tab">
       
       
       
       <!-- 实践课 -->
        <el-tab-pane label="实践课" name="practice">
          <el-row>
            <el-col :span="2">
              <el-button type="primary" @click="addPraBtn">新建问卷</el-button>
            </el-col>
          </el-row>
          <div class="conent_list">
            <div class="card_s publish_r" v-for="(item, index) in allPracticeData">
              <el-card class="box-card" >
                <div slot="header" class="clearfix">
                  <p>问卷:  {{item.model_cm_id}}</p>
                  <i v-bind:title="item.model_cm_name">{{item.model_cm_name}}</i>
                </div>
                <div class="text item">
                  <p>客观题数量:  {{item.model_cm_op_count}}</p>
                  <p>主观题数量:  {{item.model_cm_ob_count}}</p>
                </div>
                <div class="bottom clearfix">
                  <el-button style="float: left; padding: 3px 0" type="primary" @click="viewBtn(item.model_cm_id,item.model_cm_name,item.commentDetailList)">查看</el-button>
                  <el-button style="float: left; padding: 3px 0" type="primary" :disabled="disabled" v-if="item.model_issue == 0" @click="editBtn(item.model_cm_id,item.model_cm_name,item)">编辑</el-button>
                  <!-- <el-button style="float: left; padding: 3px 0" type="success" :disabled="disabled" v-if="item.model_issue == 0" @click="published(item.model_cm_id, item.model_cm_type)">发布</el-button> -->
                  <el-button style="float: right; padding: 3px 0" type="danger" :disabled="disabled" v-if="item.model_issue == 0" @click="deleteNaire(item.model_cm_id)">删除</el-button>
                </div>
              </el-card>
              <div class="p_t" v-if="item.model_issue == 1">
                <span>已发布</span>
              </div>
            </div>
          </div>

      </el-tab-pane>

       <!-- 理论课 -->
        <el-tab-pane label="理论课" name="theory">
          <el-row>
            <el-col :span="2">
              <el-button type="primary" @click="addTheBtn">新建问卷</el-button>
            </el-col>
          </el-row>
          <div class="conent_list">
            <div class="card_s publish_r" v-for="(item, index) in allTheoryData">
              <el-card class="box-card">
                <div slot="header" class="clearfix">
                  <p>问卷:  {{item.model_cm_id}}</p>
                  <i v-bind:title="item.model_cm_name">{{item.model_cm_name}}</i>
                </div>
                <div class="text item">
                  <p>客观题数量:  {{item.model_cm_op_count}}</p>
                  <p>主观题数量:  {{item.model_cm_ob_count}}</p>
                </div>
                <div class="bottom clearfix">
                  <el-button style="float: left; padding: 3px 0" type="primary" @click="viewBtn(item.model_cm_id,item.model_cm_name,item.commentDetailList)">查看</el-button>
                  <el-button style="float: left; padding: 3px 0" type="primary" :disabled="disabled" v-if="item.model_issue == 0" @click="editBtn(item.model_cm_id,item.model_cm_name,item)">编辑</el-button>
                  <el-button style="float: right; padding: 3px 0" type="danger" :disabled="disabled" v-if="item.model_issue == 0" @click="deleteNaire(item.model_cm_id)">删除</el-button>
                </div>
              </el-card>
              <div class="p_t" v-if="item.model_issue == 1">
                <span>已发布</span>
              </div>
            </div>
          </div>
        </el-tab-pane>


        
       <!-- 调查问卷 -->
        <el-tab-pane label="调查问卷" name="questionnaires">
          <el-row>
            <el-col :span="2">
              <el-button type="primary" @click="addQuestionnaires">新建问卷</el-button>
            </el-col>
          </el-row>
          <div class="conent_list">
            <div class="card_s publish_r" v-for="(item, index) in allQuestionnairesData">
              <el-card class="box-card">
                <div slot="header" class="clearfix">
                  <p>问卷:  {{item.model_cm_id}}</p>
                  <i v-bind:title="item.model_cm_name">{{item.model_cm_name}}</i>
                </div>
                <div class="text item">
                  <p>客观题数量:  {{item.model_cm_op_count}}</p>
                  <p>主观题数量:  {{item.model_cm_ob_count}}</p>
                </div>
                <div class="bottom clearfix">
                  <el-button style="float: left; padding: 3px 0" type="primary" @click="viewBtn(item.model_cm_id,item.model_cm_name,item.commentDetailList)">查看</el-button>
                  <el-button style="float: left; padding: 3px 0" type="primary" :disabled="disabled" v-if="item.model_issue == 0" @click="editBtn(item.model_cm_id,item.model_cm_name,item)">编辑</el-button>
                  <el-button style="float: right; padding: 3px 0" type="danger" :disabled="disabled" v-if="item.model_issue == 0" @click="deleteNaire(item.model_cm_id)">删除</el-button>
                </div>
              </el-card>
              <div class="p_t" v-if="item.model_issue == 1">
                <span>已发布</span>
              </div>
            </div>
          </div>
        </el-tab-pane>



      </el-tabs>
    </el-card>
    <!-- 添加实践课问卷 -->
    <el-dialog title="添加实践课问卷" :visible.sync="dialogFormPraVisible" :close-on-click-modal="false" :before-close="resetForm">
      <el-form :model="formAddPractice" ref="formAddRef" :rules="rulesPractice">
        <div class="o-box">
          <div class="add_p_conent">
            <el-form-item label="问卷名称:" prop="model_cm_name" required>
              <el-col :span="12">
                <el-input v-model.trim="formAddPractice.model_cm_name" placeholder="请输入问卷名称"></el-input>
              </el-col>
            </el-form-item>
              <el-table :data="formAddPractice.commentDetailList" stripe empty-text="暂无数据，点击左下角添加" style="width: 100%">
                <el-table-column prop="question_id" label="题号" width="160px" align="center">
                  <template slot-scope="scope">
                    <el-form-item :prop="'commentDetailList.' + scope.$index + '.question_id'" :rules="[
                      { required: true, message: '请输入题目序号！', trigger: 'blur' },
                      { type: 'number', message: '序号必须为数字值', trigger: 'blur'}]" label="第">
                      <el-input v-model.number="scope.row.question_id" style="width:80px;"></el-input>题
                    </el-form-item>
                  </template>
                </el-table-column>
                <el-table-column prop="question_describe" label="题目名称" width="450px" align="center">
                  <template slot-scope="scope">
                    <el-form-item :prop="'commentDetailList.' + scope.$index + '.question_describe'" :rules="{ required: true, message: '请输入题目名称！', trigger: 'blur' }">
                      <el-input
                        type="textarea"
                        placeholder="请输入题目名称"
                        v-model.trim="scope.row.question_describe"
                        maxlength="500"
                        show-word-limit
                        :autosize="{ minRows: 4, maxRows: 8}"
                        required
                      >
                      </el-input>
                    </el-form-item>
                  </template>
                </el-table-column>
                <el-table-column prop="question_null" label="是否必填" width="80px" align="center">
                  <template slot-scope="scope">
                    <el-form-item>
                    <el-switch
                      v-model="scope.row.question_null"
                      :active-value=1
                      :inactive-value=0
                    >
                    </el-switch>
                    </el-form-item>
                  </template>
                </el-table-column>
                <el-table-column prop="question_type" label="选项" width="105px" align="center">
                  <template slot-scope="scope">
                    <el-form-item>
                    <el-radio disabled label="1" v-if="scope.row.question_type == 2">完全符合</el-radio>
                    <el-radio disabled label="2" v-if="scope.row.question_type == 2">符合</el-radio>
                    <el-radio disabled label="3" v-if="scope.row.question_type == 2">基本符合</el-radio>
                    <el-radio disabled label="4" v-if="scope.row.question_type == 2">基本不符合</el-radio>
                    <el-radio disabled label="5" v-if="scope.row.question_type == 2">完全不符合</el-radio>
                    <el-link v-else-if="scope.row.question_type == 1">该题为主观题</el-link>
                  </el-form-item>
                  </template>
                </el-table-column>
                <el-table-column align="center"  label="移动操作" width="80px">
                  <template slot-scope="scope">
                    <el-button size="medium" type='text' style="font-size:20px;" @click.stop="configUp(scope.$index, scope.row)">↑</el-button>
                    <el-button size="medium" type='text' style="font-size:20px;" @click.stop="configDown(scope.$index, scope.row)">↓</el-button>
                  </template>
                </el-table-column>
                <el-table-column prop="del" label=删除 width="70px" align="center">
                  <template slot-scope="scope">
                    <el-button type="text" @click.native.prevent="delete_list(scope.$index, formAddPractice.commentDetailList)"><i class="el-icon-delete"></i></el-button>
                  </template>
                </el-table-column>
              </el-table>
            <el-form-item>
              <div class="btn_pra_save">
                <el-button type="primary" @click="innerDialogVisible = true" icon="el-icon-plus" circle></el-button>
              </div>
            </el-form-item>
            <el-form-item>
              <el-button @click="resetForm">取消</el-button>
              <el-button type="success" @click="sava_QS_add(is_published)">保存并发布</el-button>
              <el-button type="primary" @click="sava_QS_add(is_save)">立即保存</el-button>
            </el-form-item>
          </div>
        </div>
        <el-dialog
          width="30%"
          title="选择实践课题型"
          :visible.sync="innerDialogVisible"
          :close-on-click-modal="false"
          append-to-body>
          <el-row>
            <el-button type="primary" @click="add_question_type(type_radio)">添加客观单选</el-button>
            <el-button type="primary" @click="add_question_type(type_fill)">添加主观题</el-button>
          </el-row>
        </el-dialog>
      </el-form>
    </el-dialog>




    <!-- 添加理论课问卷 -->
    <el-dialog title="添加理论课问卷" :visible.sync="dialogFormTheVisible" :close-on-click-modal="false" :before-close="resetTheForm">
      <el-form :model="formAddTheory" ref="formTheRef" :rules="rulesTheory">
        <div class="o-box">
          <div class="add_p_conent">
            <el-form-item label="问卷名称:" prop="model_cm_name" required>
              <el-col :span="12">
                <el-input v-model.trim="formAddTheory.model_cm_name" placeholder="请输入问卷名称"></el-input>
              </el-col>
            </el-form-item>
          <el-table :data="formAddTheory.commentDetailList" stripe empty-text="暂无数据，点击左下角添加" style="width: 100%">
            <el-table-column prop="question_id" label="题号" width="160px" align="center">
              <template slot-scope="scope">
                <el-form-item :prop="'commentDetailList.' + scope.$index + '.question_id'" :rules="[
                  { required: true, message: '请输入题目序号！', trigger: 'blur' },
                  { type: 'number', message: '序号必须为数字值', trigger: 'blur'}]" label="第">
                  <el-input v-model.number="scope.row.question_id" style="width:80px;"></el-input>题
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column prop="question_describe" label="题目名称" width="400px" align="center">
              <template slot-scope="scope">
                <el-form-item :prop="'commentDetailList.' + scope.$index + '.question_describe'" :rules="{ required: true, message: '请输入题目名称！', trigger: 'blur' }">
                  <el-input
                    type="textarea"
                    placeholder="请输入题目名称"
                    v-model.trim="scope.row.question_describe"
                    maxlength="500"
                    show-word-limit
                    :autosize="{ minRows: 4, maxRows: 8}"
                    required
                  >
                  </el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column prop="question_null" label="是否必填" width="80px" align="center">
              <template slot-scope="scope">
                <el-form-item>
                <el-switch
                  v-model="scope.row.question_null"
                  :active-value=1
                  :inactive-value=0
                >
                </el-switch>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column prop="question_type" label="选项" width="105px" align="center">
              <template slot-scope="scope">
                <el-form-item>
                <el-radio disabled label="1" v-if="scope.row.question_type == 2">完全符合</el-radio>
                <el-radio disabled label="2" v-if="scope.row.question_type == 2">符合</el-radio>
                <el-radio disabled label="3" v-if="scope.row.question_type == 2">基本符合</el-radio>
                <el-radio disabled label="4" v-if="scope.row.question_type == 2">基本不符合</el-radio>
                <el-radio disabled label="5" v-if="scope.row.question_type == 2">完全不符合</el-radio>
                <el-link v-else-if="scope.row.question_type == 1">该题为主观题</el-link>
              </el-form-item>
              </template>
            </el-table-column>
            <el-table-column align="center"  label="移动操作" width="80px">
              <template slot-scope="scope">
                <el-button size="medium" type='text' style="font-size:20px;" @click.stop="configUp(scope.$index, scope.row)">↑</el-button>
                <el-button size="medium" type='text' style="font-size:20px;" @click.stop="configDown(scope.$index, scope.row)">↓</el-button>
              </template>
            </el-table-column>
            <el-table-column prop="del" label=删除 width="70px" align="center">
              <template slot-scope="scope">
                <el-button type="text" @click.native.prevent="delete_list(scope.$index, formAddTheory.commentDetailList)"><i class="el-icon-delete"></i></el-button>
              </template>
            </el-table-column>
          </el-table>
          <el-form-item>
            <div class="btn_pra_save">
              <el-button type="primary" @click="innerDialogVisible = true" icon="el-icon-plus" circle></el-button>
            </div>
          </el-form-item>
          <el-form-item>
            <el-button @click="resetTheForm">取 消</el-button>
            <el-button type="success" @click="sava_The_add(is_published)">保存并发布</el-button>
            <el-button type="primary" @click="sava_The_add(is_save)">立即保存</el-button>
          </el-form-item>
          </div>
        </div>
        <el-dialog
          width="30%"
          title="选择理论课题型"
          :visible.sync="innerDialogVisible"
          :close-on-click-modal="false"
          append-to-body>
          <el-row>
            <el-button type="primary" @click="add_question_type(type_radio)">添加客观单选</el-button>
            <el-button type="primary" @click="add_question_type(type_fill)">添加主观题</el-button>
          </el-row>
        </el-dialog>
      </el-form>
    </el-dialog>


<!-- 添加理论课问卷 -->
    <el-dialog title="添加理论课问卷" :visible.sync="dialogFormTheVisible" :close-on-click-modal="false" :before-close="resetTheForm">
      <el-form :model="formAddTheory" ref="formTheRef" :rules="rulesTheory">
        <div class="o-box">
          <div class="add_p_conent">
            <el-form-item label="问卷名称:" prop="model_cm_name" required>
              <el-col :span="12">
                <el-input v-model.trim="formAddTheory.model_cm_name" placeholder="请输入问卷名称"></el-input>
              </el-col>
            </el-form-item>
          <el-table :data="formAddTheory.commentDetailList" stripe empty-text="暂无数据，点击左下角添加" style="width: 100%">
            <el-table-column prop="question_id" label="题号" width="160px" align="center">
              <template slot-scope="scope">
                <el-form-item :prop="'commentDetailList.' + scope.$index + '.question_id'" :rules="[
                  { required: true, message: '请输入题目序号！', trigger: 'blur' },
                  { type: 'number', message: '序号必须为数字值', trigger: 'blur'}]" label="第">
                  <el-input v-model.number="scope.row.question_id" style="width:80px;"></el-input>题
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column prop="question_describe" label="题目名称" width="400px" align="center">
              <template slot-scope="scope">
                <el-form-item :prop="'commentDetailList.' + scope.$index + '.question_describe'" :rules="{ required: true, message: '请输入题目名称！', trigger: 'blur' }">
                  <el-input
                    type="textarea"
                    placeholder="请输入题目名称"
                    v-model.trim="scope.row.question_describe"
                    maxlength="500"
                    show-word-limit
                    :autosize="{ minRows: 4, maxRows: 8}"
                    required
                  >
                  </el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column prop="question_null" label="是否必填" width="80px" align="center">
              <template slot-scope="scope">
                <el-form-item>
                <el-switch
                  v-model="scope.row.question_null"
                  :active-value=1
                  :inactive-value=0
                >
                </el-switch>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column prop="question_type" label="选项" width="105px" align="center">
              <template slot-scope="scope">
                <el-form-item>
                <el-radio disabled label="1" v-if="scope.row.question_type == 2">完全符合</el-radio>
                <el-radio disabled label="2" v-if="scope.row.question_type == 2">符合</el-radio>
                <el-radio disabled label="3" v-if="scope.row.question_type == 2">基本符合</el-radio>
                <el-radio disabled label="4" v-if="scope.row.question_type == 2">基本不符合</el-radio>
                <el-radio disabled label="5" v-if="scope.row.question_type == 2">完全不符合</el-radio>
                <el-link v-else-if="scope.row.question_type == 1">该题为主观题</el-link>
              </el-form-item>
              </template>
            </el-table-column>
            <el-table-column align="center"  label="移动操作" width="80px">
              <template slot-scope="scope">
                <el-button size="medium" type='text' style="font-size:20px;" @click.stop="configUp(scope.$index, scope.row)">↑</el-button>
                <el-button size="medium" type='text' style="font-size:20px;" @click.stop="configDown(scope.$index, scope.row)">↓</el-button>
              </template>
            </el-table-column>
            <el-table-column prop="del" label=删除 width="70px" align="center">
              <template slot-scope="scope">
                <el-button type="text" @click.native.prevent="delete_list(scope.$index, formAddTheory.commentDetailList)"><i class="el-icon-delete"></i></el-button>
              </template>
            </el-table-column>
          </el-table>
          <el-form-item>
            <div class="btn_pra_save">
              <el-button type="primary" @click="innerDialogVisible = true" icon="el-icon-plus" circle></el-button>
            </div>
          </el-form-item>
          <el-form-item>
            <el-button @click="resetTheForm">取 消</el-button>
            <el-button type="success" @click="sava_The_add(is_published)">保存并发布</el-button>
            <el-button type="primary" @click="sava_The_add(is_save)">立即保存</el-button>
          </el-form-item>
          </div>
        </div>
        <el-dialog
          width="30%"
          title="选择理论课题型"
          :visible.sync="innerDialogVisible"
          :close-on-click-modal="false"
          append-to-body>
          <el-row>
            <el-button type="primary" @click="add_question_type(type_radio)">添加客观单选</el-button>
            <el-button type="primary" @click="add_question_type(type_fill)">添加主观题</el-button>
          </el-row>
        </el-dialog>
      </el-form>
    </el-dialog>
    
    
    
    <!-- 添加调查问卷 -->
    <el-dialog title="添加调查问卷" :visible.sync="dialogFormTheVisible" :close-on-click-modal="false" :before-close="resetTheForm">
      <el-form :model="formAddTheory" ref="formTheRef" :rules="rulesTheory">
        <div class="o-box">
          <div class="add_p_conent">

            <el-form-item label="问卷名称:" prop="model_cm_name" required>
              <el-col :span="12">
                <el-input v-model.trim="formAddTheory.model_cm_name" placeholder="请输入问卷名称"></el-input>
              </el-col>
            </el-form-item>


          <el-table :data="formAddTheory.commentDetailList" stripe empty-text="暂无数据，点击左下角添加" style="width: 100%">
            <el-table-column prop="question_id" label="题号" width="160px" align="center">
              <template slot-scope="scope">
                <el-form-item :prop="'commentDetailList.' + scope.$index + '.question_id'" :rules="[
                  { required: true, message: '请输入题目序号！', trigger: 'blur' },
                  { type: 'number', message: '序号必须为数字值', trigger: 'blur'}]" label="第">
                  <el-input v-model.number="scope.row.question_id" style="width:80px;"></el-input>题
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column prop="question_describe" label="题目名称" width="400px" align="center">
              <template slot-scope="scope">
                <el-form-item :prop="'commentDetailList.' + scope.$index + '.question_describe'" :rules="{ required: true, message: '请输入题目名称！', trigger: 'blur' }">
                  <el-input
                    type="textarea"
                    placeholder="请输入题目名称"
                    v-model.trim="scope.row.question_describe"
                    maxlength="500"
                    show-word-limit
                    :autosize="{ minRows: 4, maxRows: 8}"
                    required
                  >
                  </el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column prop="question_null" label="是否必填" width="80px" align="center">
              <template slot-scope="scope">
                <el-form-item>
                <el-switch
                  v-model="scope.row.question_null"
                  :active-value=1
                  :inactive-value=0
                >
                </el-switch>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column prop="question_type" label="选项" width="105px" align="center">
              <template slot-scope="scope">
                <el-form-item>
                <el-radio disabled label="1" v-if="scope.row.question_type == 2">完全符合</el-radio>
                <el-radio disabled label="2" v-if="scope.row.question_type == 2">符合</el-radio>
                <el-radio disabled label="3" v-if="scope.row.question_type == 2">基本符合</el-radio>
                <el-radio disabled label="4" v-if="scope.row.question_type == 2">基本不符合</el-radio>
                <el-radio disabled label="5" v-if="scope.row.question_type == 2">完全不符合</el-radio>
                <el-link v-else-if="scope.row.question_type == 1">该题为主观题</el-link>
              </el-form-item>
              </template>
            </el-table-column>
            <el-table-column align="center"  label="移动操作" width="80px">
              <template slot-scope="scope">
                <el-button size="medium" type='text' style="font-size:20px;" @click.stop="configUp(scope.$index, scope.row)">↑</el-button>
                <el-button size="medium" type='text' style="font-size:20px;" @click.stop="configDown(scope.$index, scope.row)">↓</el-button>
              </template>
            </el-table-column>
            <el-table-column prop="del" label=删除 width="70px" align="center">
              <template slot-scope="scope">
                <el-button type="text" @click.native.prevent="delete_list(scope.$index, formAddTheory.commentDetailList)"><i class="el-icon-delete"></i></el-button>
              </template>
            </el-table-column>
          </el-table>

          
          <el-form-item>
            <div class="btn_pra_save">
              <el-button type="primary" @click="innerDialogVisible = true" icon="el-icon-plus" circle></el-button>
            </div>
          </el-form-item>
          <el-form-item>
            <el-button @click="resetTheForm">取 消</el-button>
            <el-button type="success" @click="sava_The_add(is_published)">保存并发布</el-button>
            <el-button type="primary" @click="sava_The_add(is_save)">立即保存</el-button>
          </el-form-item>
          </div>
        </div>
        <el-dialog
          width="30%"
          title="选择调查问卷题型"
          :visible.sync="innerDialogVisible"
          :close-on-click-modal="false"
          append-to-body>
          <el-row>
            <el-button type="primary" @click="add_question_type(type_radio)">添加客观单选</el-button>
            <el-button type="primary" @click="add_question_type(type_fill)">添加主观题</el-button>
          </el-row>
        </el-dialog>
      </el-form>
    </el-dialog>




    <!-- 查看 -->
    <el-dialog :title="naireTitle" :visible.sync="viewDialogVisible">
      <div class="topic_con" v-for="(item,index) in detail_cm_data" :key="index">
        <span><b v-if="item.question_null == 1">*</b>{{item.question_id}}、{{item.question_describe}}</span>
        <div class="topic_opt">
          <el-radio disabled label="1" v-if="item.question_type == 2">{{item.option_1}}</el-radio>
          <el-radio disabled label="2" v-if="item.question_type == 2">{{item.option_2}}</el-radio>
          <el-radio disabled label="3" v-if="item.question_type == 2">{{item.option_3}}</el-radio>
          <el-radio disabled label="4" v-if="item.question_type == 2">{{item.option_4}}</el-radio>
          <el-radio disabled label="5" v-if="item.question_type == 2">{{item.option_5}}</el-radio>
        </div>
      </div>
    </el-dialog>
    <!-- 编辑 -->
    <el-dialog :title="naireTitle" :visible.sync="editDialogVisible" :close-on-click-modal="false" :before-close="cancelClick">
      <el-form :model="edit_cm_ob" ref="formEditRef" :rules="rulesEditPractice">
        <div class="o-box">
          <div class="add_p_conent">
            <el-form-item label="问卷名称:" prop="model_cm_name" required>
              <el-col :span="12">
                <el-input v-model.trim="edit_cm_ob.model_cm_name" placeholder="请输入问卷名称"></el-input>
              </el-col>
            </el-form-item>
              <el-table :data="edit_cm_ob.commentDetailList" stripe empty-text="暂无数据，点击左下角添加" style="width: 100%">
                <el-table-column prop="question_id" label="题号" width="160px">
                  <template slot-scope="scope">
                    <el-form-item :prop="'commentDetailList.' + scope.$index + '.question_id'" :rules="[
                    { required: true, message: '请输入题目序号！', trigger: 'blur' },
                    { type: 'number', message: '序号必须为数字值', trigger: 'blur'}]" label="第">
                      <el-input v-model.number="scope.row.question_id" style="width:80px;"></el-input>题
                    </el-form-item>
                  </template>
                </el-table-column>
                <el-table-column prop="question_describe" label="题目名称" width="450px">
                  <template slot-scope="scope">
                    <el-form-item :prop="'commentDetailList.' + scope.$index + '.question_describe'" :rules="{ required: true, message: '请输入题目名称！', trigger: 'blur' }">
                      <el-input
                        type="textarea"
                        placeholder="请输入题目名称"
                        v-model.trim="scope.row.question_describe"
                        maxlength="500"
                        show-word-limit
                        :autosize="{ minRows: 4, maxRows: 8}"
                        required
                      >
                      </el-input>
                    </el-form-item>
                  </template>
                </el-table-column>
                <el-table-column prop="question_null" label="是否必填" width="80px">
                  <template slot-scope="scope">
                    <el-form-item>
                    <el-switch
                      v-model="scope.row.question_null"
                      :active-value=1
                      :inactive-value=0
                    >
                    </el-switch>
                    </el-form-item>
                  </template>
                </el-table-column>
                <el-table-column prop="question_type" label="选项" width="105px">
                  <template slot-scope="scope">
                    <el-form-item>
                    <el-radio disabled label="1" v-if="scope.row.question_type == 2">完全符合</el-radio>
                    <el-radio disabled label="2" v-if="scope.row.question_type == 2">符合</el-radio>
                    <el-radio disabled label="3" v-if="scope.row.question_type == 2">基本符合</el-radio>
                    <el-radio disabled label="4" v-if="scope.row.question_type == 2">基本不符合</el-radio>
                    <el-radio disabled label="5" v-if="scope.row.question_type == 2">完全不符合</el-radio>
                    <el-link v-else-if="scope.row.question_type == 1">该题为主观题</el-link>
                  </el-form-item>
                  </template>
                </el-table-column>
                <el-table-column align="center"  label="移动操作" width="80px">
                  <template slot-scope="scope">
                    <el-button size="medium" type='text' style="font-size:20px;" @click.stop="configUp(scope.$index, scope.row)">↑</el-button>
                    <el-button size="medium" type='text' style="font-size:20px;" @click.stop="configDown(scope.$index, scope.row)">↓</el-button>
                  </template>
                </el-table-column>
                <el-table-column prop="del" label=删除 width="70px">
                  <template slot-scope="scope">
                    <el-button type="text" @click.native.prevent="delete_edit_list(scope.$index, edit_cm_ob.commentDetailList, scope.row.detail_cm_id)"><i class="el-icon-delete"></i></el-button>
                  </template>
                </el-table-column>
              </el-table>
            <el-form-item>
              <div class="btn_pra_save">
                <el-button type="primary" @click="innerDialogVisible = true" icon="el-icon-plus" circle></el-button>
              </div>
            </el-form-item>
            <el-form-item>
              <el-button @click="cancelClick">取消</el-button>
              <el-button type="success" @click="sava_QS_edit(is_published)">保存并发布</el-button>
              <el-button type="primary" @click="sava_QS_edit(is_save)">立即保存</el-button>
            </el-form-item>
          </div>
        </div>

        <el-dialog
          width="30%"
          title="选择题型"
          :visible.sync="innerDialogVisible"
          :close-on-click-modal="false"
          append-to-body>
          <el-row>
            <el-button type="primary" @click="edit_question_type(type_radio)">添加客观单选</el-button>
            <el-button type="primary" @click="edit_question_type(type_fill)">添加主观题</el-button>
          </el-row>
        </el-dialog>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
  import Vue from 'vue'
  import evaluate from '@/api/evaluate';
  export default {
  name: "evaAddque",
    data(){
      return{
        activeName: 'practice', //默认激活实践课按钮
        practiceClassId: 1, //默认实践课id为1
        disabled: false, //是否禁用
        allPracticeData: '', //查询所有实践课问卷
        allTheoryData: '', //查询所有理论课问卷
        allQuestionnairesData: '', //查询所有调查问卷
        dialogFormPraVisible: false,
        innerDialogVisible: false, //内层弹窗
        type_radio: 2, //0保留,1主观题,2客观题单选,3客观题多选,4填空题
        type_fill: 1,
        is_published: true, //是否点击了发布按钮
        is_save: false,
        issue: 1,
        formAddPractice: {
          model_cm_name: '',
          commentDetailList: [{
            option_1: '完全符合',
            option_2: '符合',
            option_3: '基本符合',
            option_4: '基本不符合',
            option_5: '完全不符合',
            question_describe: '',
            question_id: '',
            question_null: 1,
            question_remark: '',
            question_type: 2,
          }],
        },
        formLabelWidth: '120px',
        //验证规则
        rulesPractice: {
          model_cm_name: [
            { required: true, message: '请输入问卷名称！', trigger: 'blur' },
            { min: 2, max: 150, message: '长度在 2 到 150 个字符', trigger: 'blur' }
          ],
        },
        commentDetailList: [],
        length_list: 0, //所有的题目数量
        length_cm_sub: 0, //主观题数量
        length_cm_ob: 0, //客观题数量


        // -----------添加实践课问卷-------------
        dialogFormTheVisible: false,
        formAddTheory: {
          model_cm_name: '',
          commentDetailList: [{
            option_1: '完全符合',
            option_2: '符合',
            option_3: '基本符合',
            option_4: '基本不符合',
            option_5: '完全不符合',
            question_describe: '',
            question_id: '',
            question_null: 1,
            question_remark: '',
            question_type: 2,
          }],
        },
        rulesTheory: {
          model_cm_name: [
            { required: true, message: '请输入问卷名称！', trigger: 'blur' },
            { min: 2, max: 150, message: '长度在 2 到 150 个字符', trigger: 'blur' }
          ],
        },
        // -----------点击查看问卷-------------
        naireTitle: '', //问卷标题
        viewDialogVisible: false,
        detail_cm_data: '',
        // -----------点击编辑问卷-------------
        editDialogVisible: false,
        rulesEditPractice: {
          model_cm_name: [
            { required: true, message: '请输入问卷名称！', trigger: 'blur' },
            { min: 2, max: 150, message: '长度在 2 到 150 个字符', trigger: 'blur' }
          ],
        },
        length_list_temp: 0,
        edit_cm_ob: {
          model_cm_name: null,
          commentDetailList: [{
            detail_cm_id: null,
            question_describe: '',
            question_null: 1,
            question_type: 2,
          }]
        },
        edit_cm_sub: {
          model_cm_name: null,
          commentDetailList: [{
            detail_cm_id: null,
            question_describe: '',
            question_null: 1,
            question_type: 2,
          }]
        },
        edit_cm_DetailList: [], //将所有新增的数据添加到数据中
        edit_ob_length: 0, //客观题数量长度
        edit_sub_length: 0, //主观题数量长度
        edit_sum_length: 0, //总题目数量长度
        length_cm_List: 0,
      }
    },
    mounted(){
      this.getAllQuestion();
    },
    methods: {
      // 删除行
      delete_list(index,row) {
        row.splice(index, 1);
      },
      // 编辑面板，有id删除，无id移除行
      delete_edit_list(index,row,detail_cm_id) {
        if (detail_cm_id == '') {
          row.splice(index, 1);
        }else{
          this.$confirm('此操作将删除此题且不可恢复, 是否继续?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            //点击确定之后,发送id到后台删除按钮进行删除
            let param = {
              detail_cm_id: detail_cm_id
            }
            evaluate.deleteDetailQuestionnaire(param).then( response => {
              if (response.data.code == 200) {
                this.$message.success('删除成功!');
                this.getAllQuestion(this.practiceClassId);
                row.splice(index, 1);
                this.editDialogVisible = true;
              } else {
                this.$message.error('删除失败,请重试...');
                this.getAllQuestion(this.practiceClassId);
              }
            })
          }).catch(() => {
            this.$message({
              type: 'info',
              message: '已取消删除'
            });          
          });
        }
      },
      // 添加客观单选
      add_question_type(data_type) {
        this.innerDialogVisible = false
        // 先判断是不是给实践课添加问卷
        if (this.practiceClassId == 1){
          //客观单选
          if (data_type == 2) {
            this.formAddPractice.commentDetailList.push({
              option_1: '完全符合',
              option_2: '符合',
              option_3: '基本符合',
              option_4: '基本不符合',
              option_5: '完全不符合',
              question_id: '',
              question_remark: '',
              question_describe: '',
              question_null: 1,
              question_type: 2,
            })
          }
          //主观题
          if (data_type == 1) {
            this.formAddPractice.commentDetailList.push({
              question_id: '',
              question_describe: '',
              question_null: 0,
              question_type: 1,
            })
          }
        }
        // 先判断是不是给理论课添加问卷
        if (this.practiceClassId == 2) {
          if (data_type == 2) {
            this.formAddTheory.commentDetailList.push({
              option_1: '完全符合',
              option_2: '符合',
              option_3: '基本符合',
              option_4: '基本不符合',
              option_5: '完全不符合',
              question_id: '',
              question_remark: '',
              question_describe: '',
              question_null: 1,
              question_type: 2,
            })
          }
          //主观题
          if (data_type == 1) {
            this.formAddTheory.commentDetailList.push({
              question_id: '',
              question_describe: '',
              question_null: 0,
              question_type: 1,
            })
          }
        }
        if (this.practiceClassId == 3) {
          if (data_type == 2) {
            this.formAddTheory.commentDetailList.push({
              option_1: '完全符合',
              option_2: '符合',
              option_3: '基本符合',
              option_4: '基本不符合',
              option_5: '完全不符合',
              question_id: '',
              question_remark: '',
              question_describe: '',
              question_null: 1,
              question_type: 2,
            })
          }
          //主观题
          if (data_type == 1) {
            this.formAddTheory.commentDetailList.push({
              question_id: '',
              question_describe: '',
              question_null: 0,
              question_type: 1,
            })
          }
        }
      },
      // 编辑时添加客观题或主观题
      edit_question_type(data_type){
        this.innerDialogVisible = false
        // 先判断是不是给实践课添加问卷
        if (this.practiceClassId == 1){
          //客观单选
          if (data_type == 2) {
            this.edit_cm_ob.commentDetailList.push({
              option_1: '完全符合',
              option_2: '符合',
              option_3: '基本符合',
              option_4: '基本不符合',
              option_5: '完全不符合',
              question_id: '',
              question_remark: '',
              question_describe: '',
              question_null: 1,
              question_type: 2,
            })
          }
          //主观题
          if (data_type == 1) {
            this.edit_cm_ob.commentDetailList.push({
              question_id: '',
              question_remark: '',
              question_describe: '',
              question_null: 0,
              question_type: 1,
            })
          }
        }
        // 先判断是不是给理论课添加问卷
        if (this.practiceClassId == 2) {
          if (data_type == 2) {
            this.edit_cm_ob.commentDetailList.push({
              detail_cm_id: null,
              option_1: '完全符合',
              option_2: '符合',
              option_3: '基本符合',
              option_4: '基本不符合',
              option_5: '完全不符合',
              question_id: '',
              question_remark: '',
              question_describe: '',
              question_null: 1,
              question_type: 2,
            })
          }
          //主观题
          if (data_type == 1) {
            this.edit_cm_ob.commentDetailList.push({
              detail_cm_id: null,
              question_id: '',
              question_describe: '',
              question_null: 0,
              question_type: 1,
            })
          }
        }
        if (this.practiceClassId == 3) {
          if (data_type == 2) {
            this.edit_cm_ob.commentDetailList.push({
              detail_cm_id: null,
              option_1: '完全符合',
              option_2: '符合',
              option_3: '基本符合',
              option_4: '基本不符合',
              option_5: '完全不符合',
              question_id: '',
              question_remark: '',
              question_describe: '',
              question_null: 1,
              question_type: 2,
            })
          }
          //主观题
          if (data_type == 1) {
            this.edit_cm_ob.commentDetailList.push({
              detail_cm_id: null,
              question_id: '',
              question_describe: '',
              question_null: 0,
              question_type: 1,
            })
          }
        }
      },
      
      
      
      handleClick() {
        if (this.activeName == 'practice') {
          this.practiceClassId = 1;
        } else if (this.activeName == 'theory') {
          this.practiceClassId = 2;
        }else if (this.activeName == 'questionnaires') {
          this.practiceClassId = 3;
        }
        this.getAllQuestion(this.practiceClassId);
      },


      // 获取所有实践课问卷
      getAllQuestion(practiceClassId) {
        practiceClassId = this.practiceClassId
        if (practiceClassId == 1) {
          evaluate.getAllQuestion(practiceClassId).then(response => {
            if (response.data.code == 200) {
              this.allPracticeData = response.data.data;
              console.log(response.data.data)
            } else {
              this.$message.warning("获取问卷失败,请重试!")
            }
          })
        }
        if (practiceClassId == 2) {
          evaluate.getAllQuestion(practiceClassId).then(response => {
            if (response.data.code == 200) {
              this.allTheoryData = response.data.data;
              console.log(response.data.data)
            } else {
              this.$message.warning("获取问卷失败,请重试!")
            }
          })
        } 
        if (practiceClassId == 3) {
          evaluate.getAllQuestion(practiceClassId).then(response => {
            if (response.data.code == 200) {
              this.allQuestionnairesData = response.data.data;
              console.log(response.data.data)
            } else {
              this.$message.warning("获取问卷失败,请重试!")
            }
          })
        } 




      },
      // 重置表单
      resetForm() {
        this.dialogFormPraVisible = false;
        this.formAddPractice = {
          model_cm_name: null,
          commentDetailList: [{
            option_1: '完全符合',
            option_2: '符合',
            option_3: '基本符合',
            option_4: '基本不符合',
            option_5: '完全不符合',
            question_id: '',
            question_remark: '',
            question_describe: '',
            question_null: 1,
            question_type: 2,
          }]
        }
        this.$refs.formAddRef.resetFields();
      },
      //打开添加实践课问卷对话框
      addPraBtn() {
        this.dialogFormPraVisible = true;
      },
      // 提交添加的问题
      sava_QS_add(data) {
        // console.log(data)
        this.$refs.formAddRef.validate((valid) => {
          if (valid) {
            let formdata = this.formAddPractice
            this.commentDetailList = [];
            this.length_list = formdata.commentDetailList.length
            for (var i = 0; i < this.length_list; i++) {
              // 判断是客观题单选
              if (formdata.commentDetailList[i].question_type == 2) {
                this.commentDetailList.push(formdata.commentDetailList[i])
                // 统计客观题数量
                this.length_cm_ob = this.commentDetailList.length
              }
            }
            // 计算得出主观题数量
            this.length_cm_sub = this.length_list - this.length_cm_ob;
           
            formdata.model_cm_ob_count = this.length_cm_sub
            formdata.model_cm_op_count = this.length_cm_ob
            formdata.model_cm_sumNo = this.length_cm_ob + this.length_cm_sub
            formdata.model_cm_role = 2
            formdata.model_cm_type = 1
            if (data) {
              this.$confirm('发布以后不能修改问卷, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
              }).then(() => {
                //点击确定之后,发送id到后台删除按钮进行删除
                formdata.model_issue = 1
                evaluate.addQuestionnaire(formdata).then(response => {
                  if (response.data.code == 200) {
                    this.$message.success('问卷添加成功!');
                    this.getAllQuestion(this.practiceClassId);
                    this.resetForm();
                  } else {
                    this.$message.error('添加失败,请重试...');
                    this.getAllQuestion(this.practiceClassId);
                    this.resetForm();
                  }
                })
              }).catch(() => {
                this.$message({
                  type: 'info',
                  message: '已取消'
                });          
              });
            }else{
              // 准备需要提交的数据
              formdata.model_issue = 0
              evaluate.addQuestionnaire(formdata).then(response => {
                if (response.data.code == 200) {
                  this.$message.success('问卷添加成功!');
                  this.getAllQuestion(this.practiceClassId);
                  this.commentDetailList = [];
                  this.resetForm();
                } else {
                  this.$message.error('添加失败,请重试...');
                  this.getAllQuestion(this.practiceClassId);
                  this.resetForm();
                }
              })
            }
          }
        });
      },



      // ---------添加理论课-----------
      addTheBtn() {
        this.dialogFormTheVisible = true;
      },
      resetTheForm() {
        this.dialogFormTheVisible = false;
        this.formAddTheory = {
          model_cm_name: null,
          commentDetailList: [{
            option_1: '完全符合',
            option_2: '符合',
            option_3: '基本符合',
            option_4: '基本不符合',
            option_5: '完全不符合',
            question_id: '',
            question_remark: '',
            question_describe: '',
            question_null: 1,
            question_type: 2,
          }]
        }
        this.$refs.formTheRef.resetFields();
      },
      // 添加理论课模板
      sava_The_add(data) {
        this.$refs.formTheRef.validate((valid) => {
          if (valid) {
            const formThedata = this.formAddTheory
            this.commentDetailList = [];
            this.length_list = formThedata.commentDetailList.length
            for (var i = 0; i < this.length_list; i++) {
              // 判断是客观题单选
              if (formThedata.commentDetailList[i].question_type == 2) {
                this.commentDetailList.push(formThedata.commentDetailList[i])
                // 统计客观题数量
                this.length_cm_ob = this.commentDetailList.length
              }
            }
            // 计算得出主观题数量
            this.length_cm_sub = this.length_list - this.length_cm_ob;
            if (this.commentDetailList.length <= 0) {
              this.$message.error('无效添加,请重试');
              return false;
            }
            formThedata.model_cm_ob_count = this.length_cm_sub
            formThedata.model_cm_op_count = this.length_cm_ob
            formThedata.model_cm_sumNo = this.length_cm_ob + this.length_cm_sub
            formThedata.model_cm_role = 2
            formThedata.model_cm_type = 2
            if (data) {
              this.$confirm('发布以后不能修改问卷, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
              }).then(() => {
                // 准备需要提交的数据
                formThedata.model_issue = 1
                evaluate.addQuestionnaire(formThedata).then(response => {
                  if (response.data.code == 200) {
                    this.$message.success('问卷添加成功!');
                    this.getAllQuestion(this.practiceClassId);
                    this.resetTheForm();
                  } else {
                    this.$message.error('添加失败,请重试...');
                    this.getAllQuestion(this.practiceClassId);
                    this.resetTheForm();
                  }
                })
              }).catch(() => {
                this.$message({
                  type: 'info',
                  message: '已取消'
                });          
              });
            }else{
              // 准备需要提交的数据
              formThedata.model_issue = 0
              evaluate.addQuestionnaire(formThedata).then(response => {
                if (response.data.code == 200) {
                  this.$message.success('问卷添加成功!');
                  this.getAllQuestion(this.practiceClassId);
                  this.resetTheForm();
                } else {
                  this.$message.error('添加失败,请重试...');
                  this.getAllQuestion(this.practiceClassId);
                  this.resetTheForm();
                }
              })
            }
          }
        });
      },




// ---------添加调查问卷-----------
addQuestionnaires() {
        this.dialogFormTheVisible = true;
      },
      resetTheForm() {
        this.dialogFormTheVisible = false;
        this.formAddTheory = {
          model_cm_name: null,
          commentDetailList: [{
            option_1: '完全符合',
            option_2: '符合',
            option_3: '基本符合',
            option_4: '基本不符合',
            option_5: '完全不符合',
            question_id: '',
            question_remark: '',
            question_describe: '',
            question_null: 1,
            question_type: 2,
          }]
        }
        this.$refs.formTheRef.resetFields();
      },
      // 添加调查问卷模板
      sava_The_add(data) {
        this.$refs.formTheRef.validate((valid) => {
          if (valid) {
            const formThedata = this.formAddTheory
            this.commentDetailList = [];
            this.length_list = formThedata.commentDetailList.length
            for (var i = 0; i < this.length_list; i++) {
              // 判断是客观题单选
              if (formThedata.commentDetailList[i].question_type == 2) {
                this.commentDetailList.push(formThedata.commentDetailList[i])
                // 统计客观题数量
                this.length_cm_ob = this.commentDetailList.length
              }
            }
            // 计算得出主观题数量
            this.length_cm_sub = this.length_list - this.length_cm_ob;
            
            formThedata.model_cm_ob_count = this.length_cm_sub
            formThedata.model_cm_op_count = this.length_cm_ob
            formThedata.model_cm_sumNo = this.length_cm_ob + this.length_cm_sub
            formThedata.model_cm_role = 2
            formThedata.model_cm_type = 3
            if (data) {
              this.$confirm('发布以后不能修改问卷, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
              }).then(() => {
                // 准备需要提交的数据
                formThedata.model_issue = 1
                evaluate.addQuestionnaire(formThedata).then(response => {
                  if (response.data.code == 200) {
                    this.$message.success('问卷添加成功!');
                    this.getAllQuestion(this.practiceClassId);
                    this.resetTheForm();
                  } else {
                    this.$message.error('添加失败,请重试...');
                    this.getAllQuestion(this.practiceClassId);
                    this.resetTheForm();
                  }
                })
              }).catch(() => {
                this.$message({
                  type: 'info',
                  message: '已取消'
                });          
              });
            }else{
              // 准备需要提交的数据
              formThedata.model_issue = 0
              evaluate.addQuestionnaire(formThedata).then(response => {
                if (response.data.code == 200) {
                  this.$message.success('问卷添加成功!');
                  this.getAllQuestion(this.practiceClassId);
                  this.resetTheForm();
                } else {
                  this.$message.error('添加失败,请重试...');
                  this.getAllQuestion(this.practiceClassId);
                  this.resetTheForm();
                }
              })
            }
          }
        });
      },









      // 打开查看页面
      viewBtn(num,title,data) {
        this.viewDialogVisible = true;
        this.naireTitle = '问卷' + num +':' + title;
        this.detail_cm_data = data;
      },
      // 编辑问卷
      editBtn(num,title,data) {
        this.editDialogVisible = true;
        this.naireTitle = '问卷' + num +':' + title;
        this.edit_cm_ob = data;
        //统计原始问卷的长度（一共有几个问题）
        this.length_list_temp = this.edit_cm_ob.commentDetailList.length
      },
      // 上下移动调整表单-上移
      configUp(index, row) {
        if (index === 0) {
          this.$message({
            message: '已经是列表中第一行!',
            type: 'warning'
          })
        } else {
          const temp = this.edit_cm_ob.commentDetailList[index - 1]
          Vue.set(this.edit_cm_ob.commentDetailList, index - 1, this.edit_cm_ob.commentDetailList[index])
          Vue.set(this.edit_cm_ob.commentDetailList, index, temp)
          this.showListbut = true
        }
      },
      // 下移
      configDown(index, row) {
        if (index === (this.edit_cm_ob.commentDetailList.length - 1)) {
          this.$message({
            message: '已经是列表中最后一行!',
            type: 'warning'
          })
        } else {
          const i = this.edit_cm_ob.commentDetailList[index + 1]
          Vue.set(this.edit_cm_ob.commentDetailList, index + 1, this.edit_cm_ob.commentDetailList[index])
          Vue.set(this.edit_cm_ob.commentDetailList, index, i)
          this.showListbut = true
        }
      },
      // 用户未提交数据，清空除原来的所有其他行
      cancelClick() {
        //清除验证规则红字 在删除节点之前 否则验证规则将找不到节点而报错
        this.$refs.formEditRef.resetFields();
        let dataList = this.edit_cm_ob.commentDetailList
        // 统计现在改变的的问卷长度是多少，即使删除了也不管，删除的话会更新问卷的长度
        var temp_len = dataList.length
        // 从新添加的行还是计算，总共添加了几行，这些并没有提交数据库，则有必要清空，并保留原来的问卷个数
        dataList.splice(this.length_list_temp, temp_len - this.length_list_temp);
        this.editDialogVisible = false;
        //防止数据用户修改数据，重新获取原始数据
        this.getAllQuestion();
      },
      // 提交编辑的数据
      sava_QS_edit(data) {
        // console.log(this.edit_cm_ob);
        // 验证通过之后
        this.$refs.formEditRef.validate((valid) => {
          if (valid) {
            const edit_ob_data = this.edit_cm_ob
            this.edit_cm_DetailList = [];
            this.length_cm_List = edit_ob_data.commentDetailList.length
            for (var i = 0; i < this.length_cm_List; i++) {
              //将所有客观题放到一个数组中统计长度
              if (edit_ob_data.commentDetailList[i].question_type == 2) {
                this.edit_cm_DetailList.push(edit_ob_data.commentDetailList[i])
                this.edit_ob_length = this.edit_cm_DetailList.length
              }
            }
            this.edit_sub_length = this.length_cm_List - this.edit_ob_length
            edit_ob_data.model_cm_ob_count = this.edit_sub_length
            edit_ob_data.model_cm_op_count = this.edit_ob_length
            edit_ob_data.model_cm_sumNo = this.length_cm_List

            if (data) {
              this.$confirm('发布以后不能修改问卷, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
              }).then(() => {
                // 准备需要提交的数据
                edit_ob_data.model_issue = 1
                evaluate.updateQuestionnaire(edit_ob_data).then( response => {
                  if (response.data.code == 200) {
                    this.$message.success('问卷更新成功!');
                    this.getAllQuestion(this.practiceClassId);
                    this.edit_ob_length = 0;
                    this.edit_sub_length = 0;
                    this.edit_sum_length = 0;
                    this.length_cm_List = 0;
                    this.cancelClick();
                  } else {
                    this.$message.error('更新失败,请重试...');
                    this.getAllQuestion(this.practiceClassId);
                    this.cancelClick();
                  }
                })
              }).catch(() => {
                this.$message({
                  type: 'info',
                  message: '已取消'
                });          
              });
            } else {
              evaluate.updateQuestionnaire(edit_ob_data).then( response => {
                if (response.data.code == 200) {
                  this.$message.success('问卷更新成功!');
                  this.getAllQuestion(this.practiceClassId);
                  this.edit_ob_length = 0;
                  this.edit_sub_length = 0;
                  this.edit_sum_length = 0;
                  this.length_cm_List = 0;
                  this.cancelClick();
                } else {
                  this.$message.error('更新失败,请重试...');
                  this.getAllQuestion(this.practiceClassId);
                  this.cancelClick();
                }
              })
            }
          }
        });
      },
      // 删除问卷
      deleteNaire(id) {
        this.$confirm('此操作将永久删除整个问卷"' + id + '"且不可恢复, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          //点击确定之后,发送id到后台删除按钮进行删除
          let param = {
            model_cm_id: id,
            model_issue: 0
          }
          evaluate.deleteQuestionnaire(param).then( response => {
            if (response.data.code == 200) {
              this.$message.success('删除成功!');
              this.getAllQuestion(this.practiceClassId);
            } else {
              this.$message.error('删除失败,请重试...');
              this.getAllQuestion(this.practiceClassId);
            }
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });          
        });
      },
      // 删除课程评价问卷信息中的具体第几题(通用方法)
      deleteDetialNaire(id) {
        this.$confirm('此操作将删除第"' + id + '"题且不可恢复, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          //点击确定之后,发送id到后台删除按钮进行删除
          let param = {
            detail_cm_id: id
          }
          evaluate.deleteDetailQuestionnaire(param).then( response => {
            if (response.data.code == 200) {
              this.$message.success('删除成功!');
              this.getAllQuestion(this.practiceClassId);
              this.editDialogVisible = true;
            } else {
              this.$message.error('删除失败,请重试...');
              this.getAllQuestion(this.practiceClassId);
            }
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });          
        });
      },
      // ========发布模板=======
      // published(id) {
      //   console.log(id);
      // }
      // // 查询所有已发布的模板
              // getAllPublished() {
              //     return http.post(SERVER_BASE + "/select/model");
              // }
    },
  }
</script>

<style scoped>
.publish_r{
  position:relative;
  background: #ccc;
  overflow: hidden;
}
.publish_r .p_t{
  width:90px;
  height:90px;
  position: absolute;
  background: #6495ED;
  top:-50px;
  right:-50px;
  transform: rotate(45deg);
  color:#fff;
}
.publish_r .p_t span{
  position: absolute;
  bottom:0;
  display: block;
  font-size: 14px;
  width:90px;
  text-align: center;
}
.text {
  font-size: 14px;
}
.conent_list {
  margin-left: -15px;
}
.item {
  margin-bottom: 18px;
}

.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}
.clearfix:after {
  clear: both
}
.clearfix p {
  font-weight: 700;
}
.clearfix i {
  font-size: 14px;
  color: #1E90FF;
  width: 180px;
  cursor: pointer;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}
.box-card {
  width: 220px;
  background-color: #E6E6FA;
}

.card_s {
  display: block;
  float: left;
  margin-left: 15px;
  margin-top: 15px;
}
.btn_pra_save{
  margin-top:10px;
}
.left_ob {
  width: 49%;
  float: left;
  /*overflow-y: scroll;*/
}
.right_sub {
  width: 49%;
  float: right;
}

.el-divider {
  height: 300px;
}
.el-dialog {
  overflow: auto;
}
.topic_con{
  text-align: left;
  margin-left: 15px;
  padding-top: 15px;
}
.topic_opt{
  margin-left: 15px;
}
</style>
<style>
.el-tabs__content {
  height: 600px;
  overflow-y: scroll;
  white-space: nowrap;
}
::-webkit-scrollbar {
  width: 0 !important;
}
::-webkit-scrollbar {
  width: 0 !important;
  height: 0;
}
.el-tabs--top {
  height: 720px;
  overflow-y: scroll;
}
.el-card__body {
  padding: 10px;
}
</style>